package com.jdk.demo.nio.charbuffer;

import java.nio.CharBuffer;

public class CharBufferAppend {
	
	public static void main(String[] args) {
		CharBuffer charbuffer = CharBuffer.allocate(15);
		System.out.println("A " + charbuffer.position());
		charbuffer.append('a');
		System.out.println("B " + charbuffer.position());
		charbuffer.append("bcdefg");
		System.out.println("C " + charbuffer.position());
		charbuffer.append("abchijklmn", 3, 8); // 将指定字符序列的子序列添加到此缓冲区
		System.out.println("D " + charbuffer.position());
		
		char[] newArray = charbuffer.array();
		for (int i = 0; i < newArray.length; i++) {
			System.out.print(newArray[i] + " ");
		}
		System.out.println();
	}

}
